package top.yongyan0624.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.yongyan0624.mapper.LessonMapper;
import top.yongyan0624.pojo.CountCredit;
import top.yongyan0624.pojo.Lesson;
import top.yongyan0624.pojo.Lesson;
import top.yongyan0624.service.LessonService;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author Yongyan
 * @description: TODO
 * @date 2020/12/25
 **/

@Service
public class LessonServiceImpl implements LessonService {
    @Autowired
    private LessonMapper lessonMapper;

    public Integer addLesson(Lesson lesson) {
        return lessonMapper.addLesson(lesson);
    }

    public Integer deleteLesson(Integer id) {
        return lessonMapper.deleteLesson(id);
    }

    public Integer updateLesson(Lesson lesson) {
        return lessonMapper.updateLesson(lesson);
    }

    public List<Lesson> findAllLesson() {
        return lessonMapper.findAllLesson();
    }

    public PageInfo<Lesson> findAllLesson(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Lesson> lessonList = lessonMapper.findAllLesson();

        return new PageInfo<Lesson>(lessonList);
    }

    public Lesson findById(Integer id) {
        return lessonMapper.findById(id);
    }

    public List<Lesson> findByName(String name) {
        return lessonMapper.findByName(name);
    }

    public List<Lesson> findLesson(Lesson lesson) {
        return lessonMapper.findLesson(lesson);
    }

    public Integer totalLesson() {
        return lessonMapper.totalLesson();
    }

    public List<CountCredit> countCredit() {
        return lessonMapper.countCredit();
    }
}
